Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ChromaDB Support. #27

Merged
merged 15 commits into from
Sep 25, 2024
Merged

Add ChromaDB Support. #27

merged 15 commits into from
Sep 25, 2024

Conversation

PatrykWyzgowski
Copy link
Contributor

Add ChromaDB Support.

Copy link
Contributor

github-actions bot commented Sep 20, 2024

🧪 Test coverage: 92.60%

Code Coverage Summary

Filename                                                                                                Stmts    Miss  Cover    Missing
----------------------------------------------------------------------------------------------------  -------  ------  -------  --------------------------------
packages/ragbits-core/src/ragbits/core/__init__.py                                                          0       0  100.00%
packages/ragbits-core/src/ragbits/core/embeddings/__init__.py                                               0       0  100.00%
packages/ragbits-core/src/ragbits/core/embeddings/base.py                                                   4       0  100.00%
packages/ragbits-core/src/ragbits/core/llms/__init__.py                                                     4       0  100.00%
packages/ragbits-core/src/ragbits/core/llms/base.py                                                        33       4  87.88%   33, 52, 88, 97
packages/ragbits-core/src/ragbits/core/llms/litellm.py                                                     25       4  84.00%   8-9, 54, 85
packages/ragbits-core/src/ragbits/core/llms/local.py                                                       24      10  58.33%   8-9, 42-47, 57, 70-71
packages/ragbits-core/src/ragbits/core/llms/types.py                                                        8       2  75.00%   24, 28
packages/ragbits-core/src/ragbits/core/llms/clients/__init__.py                                             4       0  100.00%
packages/ragbits-core/src/ragbits/core/llms/clients/base.py                                                23       0  100.00%
packages/ragbits-core/src/ragbits/core/llms/clients/exceptions.py                                          14       6  57.14%   7-8, 17, 26-27, 36
packages/ragbits-core/src/ragbits/core/llms/clients/litellm.py                                             50      10  80.00%   10-11, 70, 108, 122-127
packages/ragbits-core/src/ragbits/core/llms/clients/local.py                                               37      12  67.57%   11-12, 62-70, 92-103
packages/ragbits-core/src/ragbits/core/prompt/__init__.py                                                   2       0  100.00%
packages/ragbits-core/src/ragbits/core/prompt/base.py                                                      18       0  100.00%
packages/ragbits-core/src/ragbits/core/prompt/parsers.py                                                   34       0  100.00%
packages/ragbits-core/src/ragbits/core/prompt/prompt.py                                                    96       2  97.92%   103, 107
packages/ragbits-core/tests/unit/__init__.py                                                                0       0  100.00%
packages/ragbits-core/tests/unit/llms/__init__.py                                                           0       0  100.00%
packages/ragbits-core/tests/unit/llms/test_litellm.py                                                      63       0  100.00%
packages/ragbits-core/tests/unit/prompts/__init__.py                                                        0       0  100.00%
packages/ragbits-core/tests/unit/prompts/test_parsers.py                                                   65       0  100.00%
packages/ragbits-core/tests/unit/prompts/test_prompt.py                                                    81       0  100.00%
packages/ragbits-dev-kit/src/ragbits/dev_kit/__init__.py                                                    0       0  100.00%
packages/ragbits-dev-kit/src/ragbits/dev_kit/prompt_lab/__init__.py                                         0       0  100.00%
packages/ragbits-dev-kit/src/ragbits/dev_kit/prompt_lab/discovery/__init__.py                               2       0  100.00%
packages/ragbits-dev-kit/src/ragbits/dev_kit/prompt_lab/discovery/prompt_discovery.py                      38       1  97.37%   62
packages/ragbits-dev-kit/tests/unit/discovery/prompt_classes_for_tests.py                                  27       0  100.00%
packages/ragbits-dev-kit/tests/unit/discovery/test_prompt_discovery.py                                     25       0  100.00%
packages/ragbits-dev-kit/tests/unit/discovery/ragbits_tests_pkg_with_prompts/__init__.py                    2       0  100.00%
packages/ragbits-dev-kit/tests/unit/discovery/ragbits_tests_pkg_with_prompts/prompts/__init__.py            3       0  100.00%
packages/ragbits-dev-kit/tests/unit/discovery/ragbits_tests_pkg_with_prompts/prompts/temp_prompt1.py       14       0  100.00%
packages/ragbits-dev-kit/tests/unit/discovery/ragbits_tests_pkg_with_prompts/prompts/temp_prompt2.py       14       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/__init__.py                                    2       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/_main.py                                      34       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/documents/__init__.py                          0       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/documents/document.py                         55       3  94.55%   52, 95, 124
packages/ragbits-document-search/src/ragbits/document_search/documents/element.py                          30       1  96.67%   34
packages/ragbits-document-search/src/ragbits/document_search/documents/sources.py                          45       8  82.22%   13-14, 58, 87, 106, 109, 120-121
packages/ragbits-document-search/src/ragbits/document_search/ingestion/__init__.py                          0       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/ingestion/document_processor.py               21       1  95.24%   80
packages/ragbits-document-search/src/ragbits/document_search/ingestion/providers/__init__.py                0       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/ingestion/providers/base.py                   14       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/ingestion/providers/dummy.py                  11       1  90.91%   29
packages/ragbits-document-search/src/ragbits/document_search/ingestion/providers/unstructured.py           26       4  84.62%   79-89, 93
packages/ragbits-document-search/src/ragbits/document_search/retrieval/__init__.py                          0       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/retrieval/rephrasers/__init__.py               0       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/retrieval/rephrasers/base.py                   5       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/retrieval/rephrasers/noop.py                   5       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/__init__.py                0       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/base.py                    6       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/retrieval/rerankers/noop.py                    7       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/vector_store/__init__.py                       0       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/vector_store/base.py                          12       0  100.00%
packages/ragbits-document-search/src/ragbits/document_search/vector_store/chromadb_store.py                75       3  96.00%   10-11, 133
packages/ragbits-document-search/src/ragbits/document_search/vector_store/in_memory.py                     18       0  100.00%
packages/ragbits-document-search/tests/__init__.py                                                          0       0  100.00%
packages/ragbits-document-search/tests/helpers.py                                                           3       0  100.00%
packages/ragbits-document-search/tests/integration/__init__.py                                              0       0  100.00%
packages/ragbits-document-search/tests/integration/test_unstructured.py                                    38      24  36.84%   22-29, 37-43, 51-57, 65-72
packages/ragbits-document-search/tests/unit/__init__.py                                                     0       0  100.00%
packages/ragbits-document-search/tests/unit/test_chromadb_store.py                                         88       1  98.86%   34
packages/ragbits-document-search/tests/unit/test_document_processor.py                                     11       0  100.00%
packages/ragbits-document-search/tests/unit/test_document_search.py                                        14       0  100.00%
packages/ragbits-document-search/tests/unit/test_documents.py                                              13       0  100.00%
packages/ragbits-document-search/tests/unit/test_elements.py                                               15       0  100.00%
packages/ragbits-document-search/tests/unit/test_gcs_source.py                                             14       0  100.00%
packages/ragbits-document-search/tests/unit/test_providers.py                                              22       0  100.00%
packages/ragbits-document-search/tests/unit/test_simple_vector_store.py                                    16       0  100.00%
TOTAL                                                                                                    1310      97  92.60%

Diff against main

Filename                                                                                       Stmts    Miss  Cover
-------------------------------------------------------------------------------------------  -------  ------  -------
packages/ragbits-document-search/src/ragbits/document_search/vector_store/chromadb_store.py      +75      +3  +96.00%
packages/ragbits-document-search/tests/unit/test_chromadb_store.py                               +88      +1  +98.86%
TOTAL                                                                                           +163      +4  +0.71%

Results for commit: 25275d1

Minimum allowed coverage is 60%

♻️ This comment has been updated with latest results

@PatrykWyzgowski PatrykWyzgowski self-assigned this Sep 20, 2024
@PatrykWyzgowski PatrykWyzgowski requested review from akotyla and micpst and removed request for micpst and akotyla September 20, 2024 12:24
Copy link
Contributor

github-actions bot commented Sep 20, 2024

Trivy scanning results.

.venv/lib/python3.10/site-packages/PyJWT-2.9.0.dist-info/METADATA (secrets)

Total: 1 (MEDIUM: 1, HIGH: 0, CRITICAL: 0)

MEDIUM: JWT (jwt-token)
════════════════════════════════════════
JWT token
────────────────────────────────────────
.venv/lib/python3.10/site-packages/PyJWT-2.9.0.dist-info/METADATA:80
────────────────────────────────────────
78 >>> encoded = jwt.encode({"some": "payload"}, "secret", algorithm="HS256")
79 >>> print(encoded)
80 [ *********************************************************************************************************
81 >>> jwt.decode(encoded, "secret", algorithms=["HS256"])
────────────────────────────────────────

.venv/lib/python3.10/site-packages/litellm/proxy/_types.py (secrets)

Total: 1 (MEDIUM: 1, HIGH: 0, CRITICAL: 0)

MEDIUM: Slack (slack-web-hook)
════════════════════════════════════════
Slack Webhook
────────────────────────────────────────
.venv/lib/python3.10/site-packages/litellm/proxy/_types.py:1287
────────────────────────────────────────
1285 alert_to_webhook_url: Optional[Dict] = Field(
1286 None,
1287 [ description="Mapping of alert type to webhook url. e.g. alert_to_webhook_url: {'budget_alerts': '*****************************************************************************'}",
1288 )
────────────────────────────────────────

from ragbits.document_search.vector_store.in_memory import InMemoryVectorStore, VectorDBEntry


class ChromaDBStore(InMemoryVectorStore):
Copy link
Member

@mhordynski mhordynski Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it derives from InMemoryVectorStory? It should be VectorStore base class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider it done.



def test_is_json_valid_string(mock_chromadb_store):
# Arrange
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice that you used AAA formatting for this test, could you also apply it to others ? Also, IMO comments are not necessary, only newlines for readability are useful.

Copy link
Contributor Author

@PatrykWyzgowski PatrykWyzgowski Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akonarski-ds it was covered in separate pull request.

@mhordynski mhordynski linked an issue Sep 23, 2024 that may be closed by this pull request
@PatrykWyzgowski PatrykWyzgowski merged commit 7833615 into main Sep 25, 2024
3 checks passed
@mhordynski mhordynski deleted the pw/add-chromadb-support branch November 21, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(document-search): add chromadb support
3 participants